<?php

/**
 * NOTICE OF LICENSE
 *
 * THIS SOURCE FILE IS PART OF EVEBIT'S PRIVATE PROJECT.
 * 
 * DO NOT USE THIS FILE IN OTHER PLACE.
 *
 * @category  Evebit
 * @package   App_Model
 * @author    Cheng Wei <berlios.o@gmail.com>
 * @version   $$Id: Collection.php 130 2011-03-18 03:10:02Z cheng.wei $$
 * @copyright Copyright (c) 2008 Evebit Inc. China (http://www.evebit.com)
 */

/**
 * model collection
 * 
 * @package App_Model
 * @author  Cheng Wei <berlios.o@gmail.com>
 * @version $$Id: Collection.php 130 2011-03-18 03:10:02Z cheng.wei $$
 */
class Evebit_Model_Mysql_Collection extends Evebit_Model_Mysql_Collection_Abstract
{
    protected function _construct()
    {
        $this->_init($this->_itemObjectClass);
    }
	
    public function _setDistinctTotalRecords(){    
    	$this->_renderFilters();
        $select = clone $this->getSelect();
        $select->reset(Zend_Db_Select::ORDER);
        $select->reset(Zend_Db_Select::LIMIT_COUNT);
        $select->reset(Zend_Db_Select::LIMIT_OFFSET);
        $select->reset(Zend_Db_Select::COLUMNS);
        $select->from('', 'main_table.*');        
        $select =	"select count(*) from (".$select.") temp";        
    	$this->_totalRecords = $this->getConnection()->fetchOne($select);
    }
}
